<%--
  Created by IntelliJ IDEA.
  User: Albert Lee
  Date: 2020/5/25
  Time: 9:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" import="java.sql.*"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <head><base href="<%=basePath%>">
    </head>
<body>
<%
    request.setCharacterEncoding("UTF-8");
    String name = request.getParameter("name");
    String pwd =  request.getParameter("password");
%>
<%
    Class.forName("com.mysql.cj.jdbc.Driver");
//桥接
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/demo","root","123456");
//连接数据库
    Statement statement=con.createStatement();
//语句对象
    String sql = "select * from user where name='"+ name +"'and pwd='"+ pwd + "'";
    ResultSet rs=statement.executeQuery(sql);
//语句对象
    if(rs.next()){
        response.sendRedirect("loginsuccess.jsp");
    }else{
        response.sendRedirect("login.jsp");
    }
    rs.close();
    statement.close();
    con.close();

%>


</body>
</html>
